/*
 * =====================================================================================
 *
 *       Filename:  Singleton.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2015年02月25日 13时06分06秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  LiuYi (), swliuyi@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <limits.h>
#include <iostream>

using namespace std;

class Singleton
{
    private:
        static Singleton * m_instance;
        Singleton(){}
    public:
        static Singleton * GetInstance()
        {
            if( m_instance == NULL )
            {
                m_instance = new Singleton();
            }
            return m_instance;
        }
};

Singleton * Singleton::m_instance = NULL;

int main(int argc, char *argv[])
{
    Singleton * s1 = Singleton::GetInstance();
    Singleton * s2 = Singleton::GetInstance();
    if( s1 == s2 )
    {
        cout<<"same instance"<<endl;
    }
    return 0;
}
